package com.bright.cwduijie.duijie.service.impl;

import com.bright.cwduijie.duijie.enums.DataApi;
import com.bright.cwduijie.duijie.enums.OpType;
import com.bright.cwduijie.duijie.enums.SJJHBZ;
import com.bright.cwduijie.duijie.pojo.bo.ApiDataCollection;
import com.bright.cwduijie.duijie.pojo.po.BioAssets;
import com.bright.cwduijie.duijie.pojo.po.FixedAssets;
import com.bright.cwduijie.duijie.pojo.query.DuijieQuery;
import com.bright.cwduijie.duijie.repository.BioAssetsRepository;
import com.bright.cwduijie.duijie.repository.FixedAssetsRepository;
import com.bright.cwduijie.duijie.service.AbstractPerThousandApiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.function.Function;

/**
 * @Author hxj
 * @Date 2024/7/29 16:25
 * @Description
 */

@Component
@RequiredArgsConstructor
@Slf4j
public class ApiBioAssetsServiceImpl extends AbstractPerThousandApiService<BioAssets> {

    private final BioAssetsRepository repo;

    @Override
    public JpaSpecificationExecutor getJpaSpecificationExecutor() {
        return repo;
    }

    @Override
    public DataApi getDataApi() {
        return DataApi.BIO_ASSETS;
    }

    @Override
    public Function<BioAssets, Integer> getIdFunc() {
        return BioAssets::getID;
    }

    @Override
    public Function<BioAssets, String> getDataKeyFunc() {
        return BioAssets::getDATA_KEY;
    }

    @Override
    public Function<ApiDataCollection, List<BioAssets>> getDataFunc() {
        return ApiDataCollection::getBioAssets;
    }

    @Override
    protected DataApi getDeleteDataApi() {
        return DataApi.DELETE_BIO_ASSETS;
    }


    @Override
    protected void getData(ApiDataCollection apiDataCollection, DuijieQuery duijieQuery) {
//        List<BioAssets> assets = repo.findAll(getDataQuerySpecification(OpType.ADD_OR_EDIT.getValue(), duijieQuery.getCreditCode()));
        apiDataCollection.setBioAssets(getNeedDuijieData(duijieQuery));
    }

//    @Override
//    protected List<BioAssets> getNeedDeleteData(DuijieQuery duijieQuery) {
//        return repo.findAll(getDataQuerySpecification(OpType.DEL.getValue(), duijieQuery.getCreditCode()));
//    }
}
